package com.qidian.mq.consumers;

import com.qidian.mq.pojo.User;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @Author 戴着假发的程序员
 * @Company 起点编程
 * @date 2023/5/25 10:18
 */
@Component// 交给spring管理
public class StMessageReceive {
    int count = 0;

    // 这里要明确配置接收消息的队列的名称
//    @RabbitListener(queues = "stQueue")
//    public void getSimpleMessage(String msg){
//        System.out.println("接收到消息("+(++count)+"):" + msg);
//    }

    @RabbitListener(queues = "stQueue")
    public void getWork1Message(String msg){
        System.out.println("消费者1接收到消息("+(++count)+"):" + msg);
    }
    @RabbitListener(queues = "stQueue")
    public void getWork2Message(String msg){
        System.out.println("消费者2接收到消息("+(++count)+"):" + msg);
    }
    @RabbitListener(queues = "stQueue")
    public void getWork3Message(String msg){
        System.out.println("消费者3接收到消息("+(++count)+"):" + msg);
    }


    @RabbitListener(queues = "stQueueA")
    public void getFanoutExchangeAMessage(String msg){
        System.out.println("接收端A:" + msg);
    }
    @RabbitListener(queues = "stQueueB")
    public void getFanoutExchangeBMessage(String msg){
        System.out.println("接收端B:" + msg);
    }
    @RabbitListener(queues = "stQueueC")
    public void getFanoutExchangeCMessage(String msg){
        System.out.println("接收端C:" + msg);
    }


    @RabbitListener(queues = "stQueueM")
    public void getFanoutExchangeMMessage(String msg){
        System.out.println("接收端M:" + msg);
    }
    @RabbitListener(queues = "stQueueN")
    public void getFanoutExchangeNMessage(String msg){
        System.out.println("接收端N:" + msg);
    }
    @RabbitListener(queues = "stQueueP")
    public void getFanoutExchangePMessage(String msg){
        System.out.println("接收端P:" + msg);
    }


//    @RabbitListener(queues = "stQueueH")
//    public void getFanoutExchangeHMessage(String msg){
//        System.out.println("接收端H:" + msg);
//    }
//    @RabbitListener(queues = "stQueueJ")
//    public void getFanoutExchangeJMessage(String msg){
//        System.out.println("接收端J:" + msg);
//    }
//    @RabbitListener(queues = "stQueueK")
//    public void getFanoutExchangeKMessage(String msg){
//        System.out.println("接收端K:" + msg);
//    }

    @RabbitListener(queues = "stQueueH")
    public void getFanoutExchangeHMessage(User msg){
        System.out.println("接收端H:" + msg);
    }
    @RabbitListener(queues = "stQueueJ")
    public void getFanoutExchangeJMessage(User msg){
        System.out.println("接收端J:" + msg);
    }
    @RabbitListener(queues = "stQueueK")
    public void getFanoutExchangeKMessage(User msg){
        System.out.println("接收端K:" + msg);
    }

}
